# match_single_condition.py
import queue
from exchange_requester import ExchangeRequester
from pick.condition import Condition
from symbol_filter import SymbolFilter
from strategy import PriceAboveStrategy


def filter_single_bar_condition(condition: Condition, symbols):
    """
      匹配某一个条件的数据
    """
    data_queue = queue.Queue()

    result_list = []

    strategy = PriceAboveStrategy(condition)

    data_fetcher = ExchangeRequester(data_queue, symbols, condition.bar)

    data_processor = SymbolFilter(data_queue, strategy, result_list)

    data_fetcher.start()

    data_processor.start()

    # 等待所有数据都被处理完毕
    data_queue.join()
    data_fetcher.join()

    data_processor.join()

    print("满足条件的数据：", condition.bar)
    for result in result_list:
        print(result)

    return result_list


if __name__ == '__main__':
    filter_single_bar_condition(Condition(bar='5m', consecutive_bars=10, direction=1))
